import { TerrainEnum } from '@/enums/TerrainEnum';

/**
 * 地形切换
 * EllipsoidTerrainProvider
 * SuperMapTerrainProvider
 * VRTheWorldTerrainProvider
 */
interface TerrainProviderOptions {
    url: string;
    token?: string;
    ellipsoid?: any;
    credit?: string | any;
    proxy?: any;
    invisibility: boolean;
}

export const terrainAdd = (viewer, type: TerrainEnum, options: TerrainProviderOptions) => {
    let terrain;
    if (type === TerrainEnum.SuperMapTerrainProvider) {
        terrain = new Cesium.SuperMapTerrainProvider({
            url: options.url,
            isSct: true,
            invisibility: options.invisibility ? options.invisibility : true
        });
    } else if (type === TerrainEnum.EllipsoidTerrainProvider) {
        terrain = new Cesium.EllipsoidTerrainProvider({
            ellipsoid: Cesium.Ellipsoid.WGS84
        });
    } else if (type === TerrainEnum.VRTheWorldTerrainProvider) {
        terrain = new Cesium.VRTheWorldTerrainProvider({
            url: options.url,
            token: options.token
        });
    }

    viewer.terrainProvider = terrain;
};

//设置影像透明色容限，取值范围为0.0~1.0。0.0表示不透明。
//viewer.imageryLayers.transparentBackColorTolerance = 0;
